﻿

CREATE PROCEDURE [dbo].[proc_Employee_Wage_Move_GetItem]
	(
		@Id int
	)
AS
Begin
	Declare @RuZhiDate DateTime ,@Pid int,@Cid int,@UserName nvarchar(50)
	Select @RuZhiDate=RuZhiDate,@Pid=Pid,@Cid=Cid,@UserName=UserName From Employee Where Id=@Id

	Select 
	(isnull((select Wage from Grade where id=E.AGradeId),0)) as BasicWage
	,(isnull((select p.PostWage from Post p where p.id=E.APostId),0)) as PostWage
	--,(isnull((datediff(dd,@RuZhiDate,getdate())/360*100),0)) as WorkWage
	,(datediff(mm,ISNULL(@RuZhiDate,GetDate()),GetDate())/12*100) as WorkWage
	,(isnull((select JxWage from Post where id=E.APostId),0)) as JxWage
	,(isnull((select ManQin from Post where id=E.APostId),0)) as ManQin
	,(isnull((select AName from Employee_Allowance EA where id=(select Allowance from post p where p.id=E.APostId)),'''')) as AllowanceName
--	,isnull((select sum(EA.Amount) from Employee_Allowance EA where EA.postid=E.BPostId And EA.Pid=@Pid And EA.Cid=@Cid),0) as Allowance
,isnull((select sum(EA.Amount) from Employee_Allowance EA where EA.postid=E.APostId And EA.Pid=@Pid And EA.Cid=@Cid),0) as Allowance
	,IsNull((Select Sum(FA.Amount) From Employee_FixedAllowance FA Where FA.UserName = @UserName),0) as FixedAllowance
	From Employee_PostMove E
	Where E.EId=@Id
End